import type { Message } from '@/type'
import client from "@/api/http-client.ts";

export async function queryAllMessages() {
  const response = await client.get("/message")
  if (response.status !== 200) {
    throw new Error('failed to fetch message')
  }
  return response.data
}

export async function createMessage(message: Message) {
  // TODO 你需从在这里调用后端 API
  console.log(message)
  const response = await client.post("/message",message)
  if (response.status !== 200) {
    throw new Error('failed to create model')
  }
  return response.data
}
